package com.itmuch.usercenter.controller.user;

import com.itmuch.usercenter.domain.entity.User;
import com.itmuch.usercenter.service.user.UserService;
import com.netflix.ribbon.hystrix.FallbackHandler;
import io.seata.spring.annotation.GlobalTransactional;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RestController;

/**
 * @author : lxc
 * @date : 2021-07-14
 */
@RestController
@RequiredArgsConstructor(onConstructor = @__(@Autowired))
@Slf4j
public class TestSWController {

    private final UserService userService;


    @GlobalTransactional(rollbackFor = Exception.class)
    @GetMapping("/testSW")
    public void testSw() {
        log.info("我被请求了...");
        this.userService.testSw();
    }

    /**
     * 服务调用事务测试
     */
    @GetMapping("/test/tx")
    public void testTx() {
        log.info("我被请求了...");
        this.userService.testSw();
    }
}
